local gaojie = fk.CreateSkill{
    name = "wk_heg__gaojie",
    tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
    ["wk_heg__gaojie"] = "高节",
    [":wk_heg__gaojie"] = "锁定技，当你成为势备篇锦囊牌的目标时，取消之；当你获得带有“合纵”标记的牌后，你弃置之，然后回复1点体力。<br />"..
    "<font color = 'gray'>注：势备篇锦囊牌包括【勠力同心】【联军盛宴】【挟天子以令诸侯】【敕令】【调虎离山】【水淹七军】【火烧连营】。</font>",

    ["$wk_heg__gaojie1"] = "失路青山隐，藏名白水游。",
    ["$wk_heg__gaojie2"] = "隐居青松畔，遁走孤竹丘。",
}

---@param object Card|Player
---@param markname string
---@param suffixes string[]
---@return boolean
local function hasMark(object, markname, suffixes)
  if not object then return false end
  for mark, _ in pairs(object.mark) do
    if mark == markname then return true end
    if mark:startsWith(markname .. "-") then
      for _, suffix in ipairs(suffixes) do
        if mark:find(suffix, 1, true) then return true end
      end
    end
  end
  return false
end

gaojie:addEffect(fk.TargetConfirming,{
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
      if not player:hasSkill(gaojie.name) then return false end
      return target == player and data.card and data.card:isCommonTrick() and data.card.package.name == "strategic_advantage"
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
      data:cancelTarget(player)
      return true
  end,
})

gaojie:addEffect(fk.AfterCardsMove,{
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(gaojie.name) then return false end
    local cardInfo = {}
    for _, move in ipairs(data) do
      if move.to and move.to == player and move.toArea == Card.PlayerHand then
        for _, info in ipairs(move.moveInfo) do
          if hasMark(Fk:getCardById(info.cardId), "@@alliance-public", MarkEnum.CardTempMarkSuffix) then
            table.insert(cardInfo, info.cardId)
          end
        end
      end
    end
    if #cardInfo > 0 then
      event:setCostData(self, { cards = cardInfo })
      return true
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    if #event:getCostData(self).cards > 0 then
      player.room:throwCard(event:getCostData(self).cards, gaojie.name, player, player)
      if player:isWounded() and not player.dead then
        player.room:recover({
          who = player,
          num = 1,
          recoverBy = player,
          skillName = gaojie.name,
        })
      end
    end
  end,
})

return gaojie